#include <bits/stdc++.h>
using namespace std;
int a[200050],h[200050];
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T;
    cin>>T;
    while (T!=0){
        int n,ans=0;
        cin>>n;
        for (int i=1;i<=n;i++){
            cin>>a[i];
            if (h[a[i]]!=0) ans+=a[i];
            h[a[i]]++;
        }
        cout<<ans<<endl;
        T--;
        for (int i=1;i<=n;i++){
            h[a[i]]=0;
            a[i]=0;
        }
    }
    return 0;
}
